using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class GUI_Webpage_CancelBooking : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnAccept_Click(object sender, EventArgs e)
    {
        if (rdChoose.SelectedValue == "Cancel booking table")
        {            
            LoadTableBooking();
        }
        else
            if (rdChoose.SelectedValue == "Cancel order food")
            {
                LoadOrderFood();
            }
        btnDelete.Visible = true;
    }


    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (rdChoose.SelectedValue == "Cancel booking table")
        {
            BookingTableBll bll = new BookingTableBll();
            BookingTableInfo bookTableInfo = new BookingTableInfo();
            // get bookingID
            bookTableInfo.BookingID = txtBookingID.Text;
            // delete booking 
            bll.DeleteTableBooking(bookTableInfo);
            LoadTableBooking();
            txtBookingID.Text = "";
        }
        else
            if (rdChoose.SelectedValue == "Cancel order food")
            {
                OrderFoodBll bll = new OrderFoodBll();
                OrderFoodInfo info = new OrderFoodInfo();
                info.OrderID = txtBookingID.Text;
                bll.DeleteOrderFood(info);
                LoadOrderFood();
                txtBookingID.Text = "";
            }                
        btnDelete.Visible = false;
    }

    #region List all table booking with a bookingID provided to customer through mail
    protected void LoadTableBooking()
    {
        BookingTableDetailsBll bll = new BookingTableDetailsBll();
        BookingTableDetailsInfo info = new BookingTableDetailsInfo();
        info.BookingID = txtBookingID.Text;

        SqlDataReader reader = bll.CancelBookingTable(info);
        grvCancel.DataSource = reader;
        grvCancel.DataBind();
    }
    #endregion

    #region List all order food with a orderID provided to customer through mail
    protected void LoadOrderFood()
    {
        OrderFoodDetailsBll bll = new OrderFoodDetailsBll();
        OrderingFoodDetailsInfo info = new OrderingFoodDetailsInfo();
        info.OrderID = txtBookingID.Text;

        SqlDataReader reader = bll.CancelOrderFoodDetails(info);
        grvCancel.DataSource = reader;
        grvCancel.DataBind();
    }
    #endregion
}
